package cc.vicp.djx314.starfood.service.activity.impls;

import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import cc.vicp.djx314.starfood.service.activity.CustomerActivityService;
import cc.vicp.djx314.starfood.dao.activity.ActivityMapper;
import cc.vicp.djx314.starfood.domain.dish.Activity;

/**
 * 餐厅活动操作接口的实现类
 * @author 水山清风
 *
 */
@Service
public class CustomerActivityServiceImpl implements CustomerActivityService {
	//~属性=====================================================================
	@Autowired
	private ActivityMapper activityMapper;


	//~方法=====================================================================
	@Override
	@Transactional(readOnly = true)
	public List<Activity> getIndexActivities() {
		int offset = 0;
		List<Activity> activities = 
				activityMapper.getCacheIndexActivities(new RowBounds(offset, INDEX_ACTI_NUM));
		Assert.isTrue(activities != null && activities.size() == INDEX_ACTI_NUM,
				"获取的主页活动的List不能为空且长度一定要为" + INDEX_ACTI_NUM);
		return activities;
	}

	@Override
	@Transactional(readOnly = true)
	public Activity getActivityInfo(final Integer id) {
		return activityMapper.getActivityInfo(id);
	}

	@Override
	public List<Activity> getAllActivityEnabledSimple() {
		List<Activity> activities;
		activities = activityMapper.getAllActivityEnabledSimple();
		return activities;
	}
	//~getter和setter=====================================================================
}
